<%= form_with model: @model, class: "container-md tabular-form" do |form| %>
  <%= text_input_row form, :name %>

  <%= collection_select_input_row form, :preview_file, @model.valid_preview_files, :id, :name, help: t(".preview_file.help") %>

  <%= collection_select_input_row form,
        :creator, @creators, :id, :name_with_domain,
        include_blank: true,
        selected: @default_creator&.id,
        button: (if policy(:creator).new?
                   {
                     path: new_creator_path,
                     label: t("creators.general.new")
                   }
                 end) %>

  <% if SiteSettings.show_libraries || current_user.is_administrator? %>
    <%= unless @model.contains_other_models?
          collection_select_input_row form,
            :library, policy_scope(Library).all, :id, :name,
            include_blank: true
        end %>
  <% end %>

  <%= render "tags_edit", form: form, name: "model[tag_list]", value: @model.tags.order(taggings_count: :desc, name: :asc).map { |tag| tag.name }.join(","), label: translate(".tags"), tags: @available_tags %>

  <%= collection_select_input_row form,
        :collection, @collections, :id, :name_with_domain,
        include_blank: true,
        button: (if policy(:collection).new?
                   {
                     path: new_collection_path,
                     label: t("collections.general.new")
                   }
                 end) %>

  <%= render "links_form", form: form %>
  <%= text_input_row form, :caption %>
  <%= rich_text_input_row form, :notes, help: t(".notes.help_html") %>
  <%= select_input_row form, :license, license_select_options(selected: @model.license), include_blank: true %>
  <%= checkbox_input_row form, :sensitive %>
  <%= select_input_row form, :indexable, indexable_select_options(form.object) %>
  <%= select_input_row form, :ai_indexable, ai_indexable_select_options(form.object) if SiteSettings.allow_ai_bots %>
  <%= render "caber_relations_form", form: form %>

  <div>
    <%= form.submit translate("general.save"), class: "btn btn-primary" %>
  </div>
<% end %>
